import { Message } from "@/utils";
import { useDialogStore, useOrderStore } from "@/store";
import { GetOrderStatus } from "@/api";

export const useContent = () => {
    const dialogStore = useDialogStore();
    const orderStore = useOrderStore();

    const onPaid = async () => {
        const res = await GetOrderStatus({
            order_no: orderStore.order_no,
            type: orderStore.order_type,
        });

        if (res.data == 1) {
            window.location.reload();
        } else {
            Message().warning("订单还未支付，如已支付请手动刷新页面！");
        }
    };

    const onClose = () => {
        dialogStore.isOrderStatusDialogVisible = false;
        orderStore.order_no = "";
    };

    return {
        dialogStore,
        orderStore,
        onPaid,
        onClose,
    };
};
